package com.axonactive.training.maganedbean;

import java.util.List;

import javax.annotation.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.inject.Inject;

import com.axonactive.training.model.Category;
import com.axonactive.training.service.CategoryService;

@ManagedBean
@RequestScoped
public class CategoryBean {
	private String name;
	
	@Inject
	CategoryService categoryService;
	
	public List<Category> getCategoryList(){
		return categoryService.getCategoryList();
	}
	
	public void saveCategory(){
		Category newCategory = new Category(name);
		categoryService.saveCategory(newCategory);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
}
